package com.example.demo.repository;

import com.example.demo.bean.FileBean;
import com.example.demo.bean.StudentFileBean;
import com.example.demo.bean.UserBean;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;
import java.util.Map;

/**
 * @author zhangbiao
 * @date 2020/6/25 11:00
 * @desc 描述
 */
public interface StudentFileRepository extends JpaRepository<StudentFileBean, String> {

    public void deleteByObjId(String obj_id);

    public StudentFileBean findByObjId(String obj_id);

    @Query(value = "SELECT fl.*,u.nickname FROM t_studentfile fl,t_user u WHERE timetable_id = ?1 AND fl.student_id = u.obj_id", nativeQuery = true)
    public List<Map<String, Object>> findStudentTaskBean(String timetable_id);

    @Query(value = "SELECT COUNT(*) FROM t_studentfile WHERE timetable_id = ?1", nativeQuery = true)
    public int findTimetableCountBean(String timetable_id);
}
